<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>个人资料</title>
		<script src="__INDEX__/js/mui.min.js"></script>
		<link href="__INDEX__/css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="__INDEX__/css/iconfont.css" />
		<link rel="stylesheet" href="__INDEX__/css/style.css" />
		<link rel="stylesheet" href="__INDEX__/css/mall.css" />
		<link rel="stylesheet" href="__INDEX__/css/LArea.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
			<h1 class="mui-title">个人资料</h1>
		</header>
		<div class="mui-content ">
			<div class="gerenzl_nr">
				<form id='my_form' class="mui-input-group gerenzl_group layui-form update_form">
					<div class="gerenzl_top img-click">
						<div class="actions" style="text-align: center; padding-top: 20px;">
							<button id="test1" type="button" class="file-btn">
			   		 		<div class="layui-upload">
							  <div class="layui-upload-list" style="margin: unset;">
							    <img class="layui-upload-img" style="height:78px;width:78px;border-radius: 100%;" id="logo" src="{$info_user['logo']?$info_user['logo']:'/public/static/index/images/member.jpg'}">
							    <input type="hidden" name='logo' value="{$info_user['logo']}" id='thumb' />
							    <p id="demoText"></p>
							  </div>
							</div>  
						</button>
							<div style="font-size: 1rem; line-height: 1.5rem; margin: 10px 0px;">头像</div>
						</div>

					</div>

					<div style="height:5px;background-color: #EFEFF4;"></div>
					<div class="mui-input-row ">
						<label><em>*</em>昵称</label>
						<input type="text" id="nickname" name="nickname" value="{$info_user['nickname']}" class="mui-input-group" placeholder="请填写昵称" lay-verify="required">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>登录名/手机号</label>
						<input type="text" id="mobile" name="mobile" value="{$info_user['mobile']}" style="width: 65%;font-size: 15px;" lay-verify="required" class="mui-input-group" placeholder="请输入您的手机号码">
					</div>
					<div class="mui-input-row">
						<label><em>*</em>真实姓名</label>
						<input type="text" id="user_name" name="user_name" value="{$info_user['user_name']}" class="mui-input-group" lay-verify="required" placeholder="请输入您的真实姓名">
					</div>
					<div class="mui-input-row">
						<label>性别</label>
						<div class=" layui-input-block" style=" direction: unset;border: unset;text-align: right;">
							<input type="radio" name="sex" value="男" title="男" {if $info_user[ 'sex']=='男'}checked{/if} />
							<input type="radio" name="sex" value="女" title="女" {if $info_user[ 'sex']=='女'}checked{/if} />
						</div>
					</div>
					<div class="gerzl_btn" style="position: relative; text-align: center; line-height: 80px; height: 80px;">
						<button type="button" lay-submit lay-filter="submit_form" class="layui-btn">保存</button>
					</div>
				</form>
			</div>
		</div>
	</body>

</html>
{include file="public/footer" /}
<script>
	//提交表单
	function set_content() {
		var nickname=$("#nickname").val();
		var phone = $("#mobile").val();
		if(nickname == '') {
			layer.msg('昵称不能为空');
			onoff = true;
			return;
		}
		if(phone == '') {
			layer.msg('手机号码不能为空');
			onoff = true;
			return;
		}
		var reg = /^1[3|4|5|7|8][0-9]{9}$/; //验证规则
		if(!reg.test(phone)) {
			layer.msg('手机号码格式不正确');
			onoff = true;
			return;
		}
		$.ajax({
			type: "post",
			url: "{:url('member/member')}",
			data: $('#my_form').serialize(), //表单数据
			success: function(data) {
				layer.msg(data.msg, {
					icon: 1,
					time: 1500 //2秒关闭（如果不配置，默认是3秒）
				}, function() {
					location.href='index.html';
				});
			}
		});

	}
</script>
<script>
	//图片上传
	layui.use(['form', 'upload'], function() {
		var $ = layui.jquery,
			upload = layui.upload,
			form = layui.form;
			
		
		//监听提交
		  form.on('submit(submit_form)', function(data){
		   set_content();
		    return false;
		  });
		

		//普通图片上传
		var uploadInst = upload.render({
			elem: '#test1',
			auto: false //选择文件后不自动上传
				,
			choose: function(obj) {
				//将每次选择的文件追加到文件队列
				var files = obj.pushFile();

				//预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
				obj.preview(function(index, file, result) {
					$('#logo').attr('src', result); //图片链接（base64）
					var sendData = result.substring(result.indexOf(";base64,") + 8);
					$.post("{:url('member/upload')}", {
						value: sendData
					}, function(data) {
						if(data.code == '200') {
							$('#thumb').val(data.url);
						} else {
							layer.msg(data.msg);
						}
					});
				});
			},
			url: "{:url('member/upload')}",
			accept: 'images'
		});
	})
</script>
